#ifndef OPHIES_IRM_H
#define OPHIES_IRM_H

#include "irm_types.h"
#include "irm_helper.h"
#include "irm_callbacks.h"
#include "irm_datamodel.h"
#include "irm_objectrequest.h"
#include "irm_search.h"

#include "json/value.h"
#include "json/reader.h"

#include <QHash>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QAuthenticator>
#include <QList>
#include <QStringList>
#include <QCoreApplication>
#include <QTimer>
#include <QUrl>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QFile>
#include <assert.h>

#include <iostream>



namespace ophies
{


class IrmMain : public QCoreApplication
{
	Q_OBJECT

public:
	IrmMain();
	IrmMain(int argc, char* argv[]);
	virtual ~IrmMain();

	void init();

public slots:
	void onAboutToQuit();

protected:
	void listBase(QString cname, RequestCallback* callback);
	//void listBase(QString cname, RequestCallback* callback, QHash<QString, QString> &search);
	void listBase(QString cname, RequestCallback* callback, Search &search);
	void getBase(QString cname, QString key, RequestCallback *callback);

public:
	void listDcmStudies(RequestCallback *callback);
	//void listDcmStudies(RequestCallback *callback, QHash<QString, QString> &search);
	void listDcmStudies(RequestCallback *callback, SearchDcmStudies &search);

	void listDcmSeries(RequestCallback *callback);
	//void listDcmSeries(RequestCallback *callback, QHash<QString, QString> &search);
	void listDcmSeries(RequestCallback *callback, SearchDcmSeries &search);

	void listDcmInstances(RequestCallback *callback);
	//void listDcmInstances(RequestCallback *callback, QHash<QString, QString> &search);
	void listDcmInstances(RequestCallback *callback, SearchDcmInstances &search);
	
	void listDocsets(RequestCallback *callback);
	//void listDocsets(RequestCallback *callback, QHash<QString, QString> &search);
	void listDocsets(RequestCallback *callback, SearchDocsets &search);
	
	void listPatients(RequestCallback *callback);
	//void listPatients(RequestCallback *callback, QHash<QString, QString> &search);
	void listPatients(RequestCallback *callback, SearchPatients &search);
	 
public:
	void getDcmStudy(QString dcm_study_key, RequestCallback* callback);
	void getDcmSeries(QString dcm_series_key, RequestCallback* callback);
	void getDcmInstance(QString dcm_instance_key, RequestCallback* callback);
	void getDocset(QString docset_key, RequestCallback* callback);
	void getPatient(QString patient_key, RequestCallback* callback);
};


} // namespace ophies

#endif // IRM_H
